using System;
using System.Data;
using System.Collections.Generic;
namespace eTMS.DAO{
	/********************************BEGIN LopTinChiDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:04/09/2010 42:05:29</para>
	/// <para>Class Name: LopTinChiDAO</para>
	/// <para>Description: Class access to table LopTinChi in database. Class for coder code here</para>
	///</summary>

	
	public partial class LopTinChiDAO{
        public int CountSinhVienDangKy(int NamHoc_ID,int HocKy_ID,int MonHoc_ID)
        {
            IDbCommand cmd = this.CreateCommand();
            cmd.CommandText = @"SELECT        COUNT(SinhVien_ID) AS SOSV
                                FROM            DangKyHocPhan
                                WHERE        (SinhVien_ID NOT IN
                                                                (SELECT  SinhVienLopTinChi.SinhVien_ID
                                                                 FROM    LopTinChi INNER JOIN
                                                                         SinhVienLopTinChi ON LopTinChi.LopTinChi_ID = SinhVienLopTinChi.LopTinChi_ID
                                                                 WHERE   (LopTinChi.NamHoc_ID = @NamHoc_ID) AND (LopTinChi.HocKy_ID = @HocKy_ID) AND (LopTinChi.MonHoc_ID = @MonHoc_ID)))
                                             AND (NamHoc_ID = @NamHoc_ID) AND (HocKy_ID = @HocKy_ID) AND (MonHoc_ID = @MonHoc_ID)";
            this.CreateCommandParameter(cmd,"@NamHoc_ID",NamHoc_ID);
            this.CreateCommandParameter(cmd, "@HocKy_ID", HocKy_ID);
            this.CreateCommandParameter(cmd, "@MonHoc_ID", MonHoc_ID);
            DataSet ds = this.SelectDS(cmd);
            int rval = 0;
            int.TryParse(ds.Tables[0].Rows[0][0].ToString(),out rval);
            return rval;
        }

	}
	/*****************************************************************************************************/
	/**********************************END LopTinChiDAO*****************************************/
	/*****************************************************************************************************/
}

